package crp.core.portal.domain.services;

import crp.core.portal.domain.models.PortalSectionEntity;
import crp.core.portal.domain.repositories.PortalSectionRepository;
import crp.core.shared.LifecycleStatus;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.stream.Stream;

@ApplicationScoped
public class PortalSectionSearcher {
    private final PortalSectionRepository portalSectionRepository;

    @Inject
    public PortalSectionSearcher(PortalSectionRepository portalSectionRepository) {
        this.portalSectionRepository = portalSectionRepository;
    }

    public Stream<PortalSectionEntity> enabled() {
        return portalSectionRepository.findOrderedByStatus(LifecycleStatus.ENABLED);
    }

    public Stream<PortalSectionEntity> all() {
        return portalSectionRepository.findOrderedAll();
    }
}
